package com.imicode.tel.book.server;

import com.imicode.tel.book.Message;
import com.imicode.tel.book._OnlineBookDisp;

import Ice.Communicator;
import Ice.Current;
import Ice.ObjectAdapter;
import IceBox.Service;

public class OnlineBookImpl extends _OnlineBookDisp implements Service {
	
	private static final long serialVersionUID = 1L;
	private ObjectAdapter _adapter;

	@Override
	public Message bookTick(Message msg, Current __current) {
		System.out.println("---------------------------BookTick to call." + this.getClass().getName());
		System.out.println("Book Message: ");
		System.out.println("---------name: " + msg.name);
		System.out.println("---------type: " + msg.type);
		System.out.println("---------price: " + msg.price);
		System.out.println("---------content: " + msg.content);
		System.out.println("---------------------------BookTick successed ");
		return msg;
	}

	@Override
	public void start(String name, Communicator communicator, String[] args) {
		_adapter = communicator.createObjectAdapter(name);
		Ice.Object object = this;
		_adapter.add(object, communicator.stringToIdentity(name));
		_adapter.activate();
		System.out.println("***********************" + name + " started.");
	}

	@Override
	public void stop() {
		System.out.println("****************************" + this._adapter.getName() + " stoped.");
		_adapter.destroy();
	}

}
